<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function Login(){
        if(IS_POST){
            
         $user=M('sys_user');
         $map['loginname']=I('post.username');
         $ck=$user->where($map)->find();
         if($ck){
             
          if($ck['password']==MD5(I('post.password'))){
              if($ck['zt']==0){
                  session('empid',$ck['empid']); 
                 session('loginname',$ck['loginname']); 
            $this->success('初次登录请修改密码',U('Login/checklogin'));      
              }else{
                session('empid',$ck['empid']); 
             session('userlevel',$ck['userlevel']);
             session('loginname',$ck['loginname']);
              $this->success('登录成功,正在转向系统管理页',U('Index/Index2'));}
          }   else{
              
              $this->error('对不起密码输入错误');
          }
             
         }else{
             
          $this->error('您输入的账号不存在');   
         }
            
        }else{
        $this->display();
        }
        
    }
    public function checklogin(){
        
        $loginname=session('loginname');
        $this->assign('loginname',$loginname);
        $this->display();
    }
    public function Login2(){
        
        $this->display();
        
    }
public function logout(){
	$S=session('empid',NULL);
	
		
	$this->success('您已成功退出登录',U('Login/Login'))	;
		
	echo '<script>window.close();</script>'; 
	
	
}	
}

?>